package com.example.shaoying.yuejian.fragment.clubeFragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.shaoying.yuejian.R;
import com.example.shaoying.yuejian.adapter.ClubCourseAdapter;
import com.example.shaoying.yuejian.adapter.ClubVideoAdapter;
import com.example.shaoying.yuejian.javabean.ClubCourse;
import com.example.shaoying.yuejian.javabean.ClubVideo;
import com.example.shaoying.yuejian.model.ClubeModel;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;


public class ClubeShiPinFragment extends Fragment {
    private RecyclerView recyclerView;
    private ClubVideoAdapter adapter;

    private String map;
    private String Club_Id;
    private View view;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        view=inflater.inflate(R.layout.clube_shipin, container, false);
        Club_Id=getActivity().getIntent().getStringExtra("Club_Id");
        map="Clubvideo";

        recyclerView= (RecyclerView) view.findViewById(R.id.club_info_video);
        ClubeModel model=new ClubeModel();
        Call<ClubVideo> call=model.getClubVide(Club_Id,map);
        call.enqueue(new Callback<ClubVideo>() {
            @Override
            public void onResponse(Call<ClubVideo> call, Response<ClubVideo> response) {
                List<ClubVideo.ClubvideoEntity> res=response.body().getClubvideo();
                adapter=new ClubVideoAdapter(getActivity(),res);
                LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
                linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                recyclerView.setLayoutManager(linearLayoutManager);
                recyclerView.setAdapter(adapter);
                recyclerView.setItemAnimator(new DefaultItemAnimator());
            }

            @Override
            public void onFailure(Call<ClubVideo> call, Throwable t) {

                Toast.makeText(getActivity(),"获取列表失败",Toast.LENGTH_SHORT).show();
            }
        });
        return view;
    }


}
